package com.itcast.springbootcondition.config;

import com.itcast.springbootcondition.condition.ClassCondition;
import com.itcast.springbootcondition.domain.User;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

@Configuration

public class UserConfig {
    @Bean
   // @Conditional(ClassCondition.class)
    public User user(){
        return new User();
    }
    @Bean
    @ConditionalOnProperty(name = "itcast",havingValue = "itheima")
/*    ConditionalOnProperty：判断配置文件中是否有对应属性和值才初始化Bean
    ConditionalOnClass：判断环境中是否有对应字节码文件才初始化Bean
    ConditionalOnMissingBean：判断环境中没有对应Bean才初始化Bean*/
    public User user2(){
        return new User();
    }
}
